1
//------------------------------------------------------------------------------
3 // This code was generated by a tool.
5 // Changes to this file may cause incorrect behavior and will be lost if
6 // the code is regenerated.
8 //------------------------------------------------------------------------------
10 using DslModeling
= global::Microsoft
.VisualStudio
.Modeling
;
11 using DslDiagrams
= global::Microsoft
.VisualStudio
.Modeling
.Diagrams
;
12 using DslShell
= global::Microsoft
.VisualStudio
.Modeling
.Shell
;
14 namespace Fabrikam
.Dsl
.TestValidation
17 /// Double-derived class to allow easier code customization.
19 internal partial class TestValidationDocView
: TestValidationDocViewBase
22 /// Constructs a new TestValidationDocView.
24 public TestValidationDocView(DslShell
::ModelingDocData docData
, global::System
.IServiceProvider serviceProvider
)
25 : base(docData
, serviceProvider
)
31 /// Class that hosts the diagram surface in the Visual Studio document area.
33 internal abstract class TestValidationDocViewBase
: DslShell
::SingleDiagramDocView
36 /// Constructs a new TestValidationDocView.
38 protected TestValidationDocViewBase(DslShell
::ModelingDocData docData
, global::System
.IServiceProvider serviceProvider
) : base(docData
, serviceProvider
)
43 /// Called to initialize the view after the corresponding document has been loaded.
45 protected override bool LoadView()
49 global::System
.Diagnostics
.Debug
.Assert(this.DocData
.RootElement
!=null);
50 if (this.DocData
.RootElement
== null)
55 // The diagram should exist in the diagram partition by now, just need to find it and connect it to this view.
56 TestValidationDocDataBase docData
= this.DocData
as TestValidationDocDataBase
;
57 global::System
.Diagnostics
.Debug
.Assert(docData
!= null, "DocData for TestValidationDocViewBase should be an TestValidationDocDataBase!");
58 DslModeling::Partition diagramPartition
= docData
.GetDiagramPartition();
59 if (diagramPartition
!= null)
61 global::System
.Collections
.ObjectModel
.ReadOnlyCollection
<global::Fabrikam
.Dsl
.TestValidation
.TestValidationDiagram
> diagrams
= docData
.GetDiagramPartition().ElementDirectory
.FindElements
<global::Fabrikam
.Dsl
.TestValidation
.TestValidationDiagram
>();
62 if (diagrams
.Count
> 0)
64 global::System
.Diagnostics
.Debug
.Assert(diagrams
.Count
== 1, "Found more than one diagram, using the first one found.");
65 this.Diagram
= (DslDiagrams
::Diagram
)diagrams
[0];
81 /// Name of the toolbox tab that should be displayed when the diagram is opened.
83 protected override string DefaultToolboxTabName
87 return global::Fabrikam
.Dsl
.TestValidation
.TestValidationToolboxHelper
.DefaultToolboxTabName
;
92 /// Returns the toolbox items count in the default tool box tab.
94 protected override int DefaultToolboxTabToolboxItemsCount
98 return global::Fabrikam
.Dsl
.TestValidation
.TestValidationToolboxHelper
.DefaultToolboxTabToolboxItemsCount
;
104 /// Context menu displayed when the user right-clicks on the design surface.
106 protected override global::System
.ComponentModel
.Design
.CommandID ContextMenuId
110 return Constants
.TestValidationDiagramMenu
;
115 /// Called when selection changes in this window.
118 /// Overriden to update the F1 help keyword for the selection.
120 /// <param name="e"></param>
121 protected override void OnSelectionChanged(global::System
.EventArgs e
)
123 base.OnSelectionChanged(e
);
125 if(global::Fabrikam
.Dsl
.TestValidation
.TestValidationHelpKeywordHelper
.Instance
!= null)
127 DslModeling::ModelElement selectedElement
= this.PrimarySelection
as DslModeling
::ModelElement
;
128 if(selectedElement
!= null)
130 string f1Keyword
= global::Fabrikam
.Dsl
.TestValidation
.TestValidationHelpKeywordHelper
.Instance
.GetHelpKeyword(selectedElement
);
132 // If this is a presentation element, check the underlying model element for a help keyword
133 DslDiagrams::PresentationElement presentationElement
= this.PrimarySelection
as DslDiagrams
::PresentationElement
;
134 if(presentationElement
!= null)
136 selectedElement
= presentationElement
.ModelElement
;
137 if(selectedElement
!= null)
139 string modelElementKeyword
= global::Fabrikam
.Dsl
.TestValidation
.TestValidationHelpKeywordHelper
.Instance
.GetHelpKeyword(selectedElement
);
140 if(string.IsNullOrEmpty(f1Keyword
))
142 // Presentation element does not have an F1 keyword, so push the keyword from the model element as an F1 keyword.
143 f1Keyword
= modelElementKeyword
;
145 else if (!string.IsNullOrEmpty(modelElementKeyword
) && this.SelectionHelpService
!= null)
147 // Presentation element has an F1 keyword, so push model element keyword as a general dynamic help keyword (non-F1).
148 this.SelectionHelpService
.AddContextAttribute(string.Empty
, modelElementKeyword
, global::System
.ComponentModel
.Design
.HelpKeywordType
.GeneralKeyword
);
153 if(!string.IsNullOrEmpty(f1Keyword
) && this.SelectionHelpService
!= null)
155 this.SelectionHelpService
.AddContextAttribute(string.Empty
, f1Keyword
, global::System
.ComponentModel
.Design
.HelpKeywordType
.F1Keyword
);